package com.itheima;

public class demo07_02 {
    private static int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9};

    public static void exchanged(int start, int end) {
        if (end <= start)
            return;
        if (arr[start] % 2 == 1) {
            exchanged(++start, end);
        } else {
            if (arr[end] % 2 == 0) {
                exchanged(start, --end);
            } else {
                int temp = arr[start];
                arr[start] = arr[end];
                arr[end] = temp;
                exchanged(++start, end);
            }
        }
    }

    public static void main(String[] args) {
        exchanged(0, arr.length - 1);
        for (int k = 0; k < arr.length; k++) {
            System.out.println(arr[k]);
        }
    }
}
